package start

import (
	"forum/ioc"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
)

func InitDB() *gorm.DB {
	dsn := "root:root@tcp(localhost:13319)/testdb"
	var err error
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	ioc.CreateTable(db)
	if err != nil {
		log.Fatalf("Could not connect to database: %s", err)
	}
	return db
}
